{% extends 'base/base.html' %}
{% block stylesheets %}
    {{ block.super }}
   <link href="/static/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block content %}
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>

            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <a href="{% url 'project_add' %}" style="float:left;" class="btn btn-info btn-sm"
                               role="button" {% if not perms.deploy.edit_deploy %}disabled{% endif %}><i
                                    class="fa fa-plus"></i></a>
                            <div class="loading"></div>
                            <h2>代码发布项目 </h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <form class="form-horizontal form-border" method="get" action="" name="formName">
                            <div class="x_content table-responsive" style="border:none">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th>详细</th>
                                        <th>项目名称</th>
                                        <th>目标路径</th>
                                        <th>部署路径</th>

                                        {% if perms.deploy.edit_deploy %}
                                            <th>操作</th>
                                        {% endif %}
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for each_project in all_project_list %}
                                        <tr>
                                            <td><a href="{% url 'project_list' %}?aid={{ each_project.pk }}"><i
                                                    class="fa fa-envelope"></i></a></td>
                                            <td>{{ each_project.name }}</td>
                                            <td>{{ each_project.target_path }}</td>
                                            <td>{{ each_project.deploy_path }}</td>
                                            {% if perms.deploy.edit_deploy %}
                                                <td>
                                                    <a href="{% url 'project_manage' aid=each_project.pk action='edit' %}"
                                                       class="btn btn-success btn-sm" role="button"><i
                                                            class="fa fa-edit"></i></a>
                                                    <a href="#" data-toggle="modal"
                                                       data-target="#reqDelete-{{ each_project.pk }}"
                                                       class="btn btn-danger btn-sm" role="button"><i
                                                            class="fa fa-trash-o "></i></a>
                                                </td>
                                            {% endif %}
                                            <!-- 模态框（Modal） -->
                                            <div class="modal fade" id="reqDelete-{{ each_project.pk }}" tabindex="-1"
                                                 role="dialog" aria-labelledby="reqDelete" aria-hidden="true">
                                                <div class="modal-dialog">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"
                                                                    aria-hidden="true">&times;
                                                            </button>
                                                            <h4 class="modal-title" id="reqDelete">提示</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            确认是否删除？
                                                            <div><br/><strong>{{ each_project.name }}</strong></p></div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-default btn-sm"
                                                                    data-dismiss="modal">关闭
                                                            </button>
                                                            <a style="margin:4px;" class="btn btn-danger btn-sm"
                                                               href="{% url 'project_manage' aid=each_project.pk action='delete' %}">删除</a>
                                                        </div>
                                                    </div><!-- /.modal-content -->
                                                </div><!-- /.modal-dialog -->
                                            </div><!-- /.modal -->
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block javascripts %}
    {{ block.super }}
    <script src="/static/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
{% endblock %}
